// components/good/good.js
import util from '../../../utils/utils'
import {
  HomeHttp
} from '../../../api/home.js'
const homeModel = new HomeHttp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    cardInfo: Object, // 商品信息
    show: {
      type: Boolean,
      value: true
    },
    newTime: Number
  },

  /**
   * 组件的初始数据
   */
  /**
   * 组件的方法列表
   */
  methods: {
    getAddress(e) {
      console.log(this.data.cardInfo);
      this.triggerEvent('getAddress', this.data.cardInfo);
    },
    //点击取消按钮
    goToDetails() {
      wx.navigateTo({
        url: '/pages/order/ownOrder/ownOrder?id=' + this.data.cardInfo.orderId
      })
    },
    //付款按钮
    onPay(){
      this.triggerEvent('onPay', this.data.cardInfo);
    },
    //确认收货
    confirmBtn() {
      let self = this
      console.log(self.data)
      wx.showModal({
        title: '是否确认收货',
        success: function(res) {
          if (res.confirm) {
            homeModel.getFinishOrder({
              orderNumber: self.data.cardInfo.orderId
            }).then((res) => {
              self.triggerEvent('refreshData')
            })

          }
        },
      })
    },
  }
});